package com.cn.component.valdation;

import com.cn.component.ValdationConfig;
import com.jfinal.core.Controller;
/**
 * 初始化
 * @author Administrator
 *
 */
public class StartCapthcaController extends Controller{

	public void index() {
		GeetestLib gtSdk = new GeetestLib();
		gtSdk.setCaptchaId(ValdationConfig.getCaptcha_id());
		gtSdk.setPrivateKey(ValdationConfig.getPrivate_key());

		gtSdk.setGtSession(getRequest());

		String resStr = "{}";

		if (gtSdk.preProcess() == 1) {
			// gt server is in use
			resStr = gtSdk.getSuccessPreProcessRes();
			gtSdk.setGtServerStatusSession(getRequest(), 1);

		} else {
			// gt server is down
			resStr = gtSdk.getFailPreProcessRes();
			gtSdk.setGtServerStatusSession(getRequest(), 0);
		}
		renderText(resStr);
	}
}
